/**
 * MineAdmin is committed to providing solutions for quickly building web applications
 * Please view the LICENSE file that was distributed with this source code,
 * For the full copyright and license information.
 * Thank you very much for using MineAdmin.
 *
 * @Author X.Mo<root@imoi.cn>
 * @Link   https://github.com/mineadmin
 */

import type { MaSearchItem } from "@mineadmin/search";
import { rdOrganizeAreaStatusDictData } from "./common.tsx";
import MaDictSelect from "@/components/ma-dict-picker/ma-dict-select.vue";
import MaDictRadio from "@/components/ma-dict-picker/ma-dict-radio.vue";

import { page as getProjLineList } from '@/plugins/ai-warning/organization/api/rdOrganizeProjLine.ts'
import MaRemoteSelect from '@/components/ma-remote-select/index.vue'
export default function getSearchItems(t: any): MaSearchItem[] {
  return [
    // {
    //   label: "所属项目",
    //   prop: "proj_line_id",
    //   render: () => MaDictSelect,
    //   renderProps: { multiple: false },
    // },
    { 
      label: '所属项目线', 
      prop: 'proj_line_id', 
      render: () => MaRemoteSelect, 
      renderProps: { 
        api: getProjLineList,
        axiosConfig: {
          autoRequest: true,
          params: {
            page: 1,
            pageSize: 1000,
          }
        },
        dataHandle: (response: any) => {
          if (response.code === 200 && response.data && response.data.list) {
            return response.data.list.map((projLine: any) => ({
              label: projLine.name,
              value: projLine.id,
            }));
          }
          return [];
        },
        placeholder: t('form.pleaseSelect', { msg: '所属项目线' }),
        filterable: true,
        clearable: true,
      }, 
    },
    {
      label: "工区名称",
      prop: "name",
      render: "input",
      renderProps: { placeholder: t("form.pleaseInput", { msg: "工区名称" }) },
    },
    {
      label: "状态",
      prop: "status",
      render: () => MaDictRadio,
      renderProps: { multiple: false, data: rdOrganizeAreaStatusDictData() },
    },
  ];
}
